<template>
	<view class="container">
		<view class="card" v-if="listdata && listdata[0]" v-for="(item,index) in listdata" :key="index">
			<view class="card-top">
				<view class="top-title">物料名称：{{item.type_name}}</view>
				<view class="top-tips" v-if="item.confirm_status == 0">待确认</view>
				<view class="top-tips-old" v-if="item.confirm_status == 1">已确认</view>
			</view>
			<view class="card-bottom">
				<view class="bottom-text">
					<view class="text">领用人：{{item.receive_name}}</view>
				</view>
				<view class="text">领用时间：{{item.receive_time}}</view>
				<view class="text">手机号：{{item.receive_phone}}</view>
				<view class="text">领用数量：{{item.receive_num}}</view>
				<view class="text">备 注：{{item.remark}}</view>
			</view>
			<view class="btn-box" v-if="item.confirm_status == 0">
				<button type="primary" class="btn-left" :style="'background-color:' + actcolor + ';-webkit-box-shadow:0rpx 4rpx 16rpx #b1b1b1;box-shadow:0rpx 4rpx 16rpx #b1b1b1;'" @tap="confirmPickup(item.id)">确认</button>
			</view>
		</view>
	</view>
</template>

<script>
	var common = require('../../../utils/common.js');
	var app = getApp();
	var _this;
	const getmaterialsList = () => {
		common.post('HouseApi&a=checkout_list', {
			receive_id: _this.receive_id,
		}, data => {
			console.log('++++', data)
			_this.listdata = data.list;
		});
	};
	const getconfirmPickup = () => {
		common.post('HouseApi&a=confirm_checkout', {
			receive_id: _this.receive_id,
			id: _this.pickup_id,
		}, data => {
			console.log('++++', data)
			getmaterialsList()
		});
	};
	export default {
		data() {
			return {
				listdata: {},
				numlist: {},
				village_id: 0,
				pigcms_id: 0,
				actcolor: '',
				btn_style: '',
				receive_id:'',
				pickup_id:'',
			}
		},
		onShow() {
			// #ifdef H5
			common.hideWxShare()
			// #endif
		},
		onLoad(options) {
			_this = this;
			_this.receive_id = options.receive_id
			// #ifdef H5
			console.log('准备跳小程序页', _this.id);
			common.webToMiniapp(_this.route, options, 'redirect')
			// #endif

			common.setMainColor(_this, function(config) {
				_this.actcolor = config.config.mobile_head_color
				_this.btn_style = 'background-color: ' + _this.actcolor + ';box-shadow:0px 30rpx 30rpx -30rpx ' + _this.actcolor +
					';';

				const res = uni.getStorageSync('village_key');
				if (res) {
					_this.village_id = res.village_id;
					_this.pigcms_id = res.pigcms_id;
					_this.village_name = res.village_name;
				};
				getmaterialsList()
			});
		},
		methods: {
			confirmPickup(pickup_id){
				_this.pickup_id = pickup_id;
				uni.showModal({
					title: common.changeTxt('提示'),
					content: common.changeTxt('是否确认领取'),
					showCancel: true,
					cancelText: common.changeTxt('取消'),
					confirmText: common.changeTxt('确认'),
					success: function(res) {
						if (res.confirm) {
							getconfirmPickup()
						}
					}
				});
			},
		},
		components: {

		}
	}
</script>

<style>
	page {
		background-color: rgb(245,245,245);
	}
	.container {
		margin: 0;
		padding: 0;
	}
	.card {
		margin: 30rpx;
		padding: 0rpx 30rpx 30rpx 30rpx;
		background: #FFFFFF;
		border-radius: 15rpx;
	}
	
	.card-top {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx solid #F1F1F1;
	}
	
	.card-center {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		margin-top: 15rpx;
	}
	
	.center-title {
		font-size: 32rpx;
		font-weight: 700;
		font-stretch: normal;
		line-height: 60rpx;
		letter-spacing: 0rpx;
		color: #000000;
	}
	
	.center-number {
		font-size: 32rpx;
		font-weight: 600;
		font-stretch: normal;
		line-height: 60rpx;
		letter-spacing: 0rpx;
		color: #2681f3;
	}
	
	.top-title {
		font-size: 24rpx;
		font-weight: 700;
		font-stretch: normal;
		line-height: 80rpx;
		letter-spacing: 0rpx;
		color: #333333;
	}
	
	.top-tips {
		font-size: 20rpx;
		font-weight: normal;
		font-stretch: normal;
		padding: 5rpx 10rpx;
		letter-spacing: 0rpx;
		color: #ffa112;
		background-color: #f9efd2;
		border-radius: 5rpx;
	}
	.top-tips-old {
		font-size: 20rpx;
		font-weight: normal;
		font-stretch: normal;
		padding: 5rpx 10rpx;
		letter-spacing: 0rpx;
		color: #2fd07b;
		background-color: #dbf8e9;
		border-radius: 5rpx;
	}
	.card-bottom {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
	}
	
	.bottom-text {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
	}
	
	.text {
		font-size: 24rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 50rpx;
		letter-spacing: 0rpx;
		color: #999999;
	}
	
	.tips {
		font-size: 18rpx;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 0rpx;
		color: #ffffff;
		background-color: #ffa112;
		border-radius: 4rpx;
		margin-left: 15rpx;
		padding: 0rpx 10rpx;
	}
	.tips-old {
		font-size: 18rpx;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 0rpx;
		color: #ffffff;
		background-color: #2fd07b;
		border-radius: 4rpx;
		margin-left: 15rpx;
		padding: 0rpx 10rpx;
	}
	.btn-box {
		display: flex;
		flex-direction: row;
		justify-content: flex-end;
		align-items: center;
	}
	
	.btn-left {
		background-color: #2681f3;
		border-radius: 35rpx;
		border: 0;
		font-size: 24rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 60rpx;
		letter-spacing: 0rpx;
		color: #ffffff;
		margin: 0rpx;
		margin-top: 20rpx;
		padding: 0 40rpx;
	}
	
	.btn-right {
		background-color: #2681f3;
		border-radius: 28rpx;
		border: 0;
		font-size: 24rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 50rpx;
		letter-spacing: 0rpx;
		color: #ffffff;
		margin: 0rpx;
		margin-left: 15rpx;
		padding: 0 15rpx;
	}
</style>
